(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("invoiceCreateService", invoiceCreateService);
	invoiceCreateService.$inject = [ '$q', 'loggerFactory', 'commonService', 'ajaxServiceFactory' ];
	function invoiceCreateService($q, loggerFactory, commonService, ajaxServiceFactory) {
		var log = loggerFactory.getLogger("invoiceCreateService");
		var ajaxService = ajaxServiceFactory.buildAjaxService({
			getCurrencyOptions : {
				url : 'do/cda/dataList/currenciesBySiteCode',
				method : 'get'
			},
			getCommunityCodeQOptions: {
				url : 'do/cda/dataList/communityCodeQs',
				method : 'get'					
			},
			getMaturitydate: {
				url : 'do/apf/piCreate/getMaturitydate',
				method : 'post'					
			},
			getInvoiceTypeOptions: {
				url : 'do/apf/dataList/getInvoiceTypeOptions',
				method : 'post'					
			},
			getCalendarCodes: {
				url : 'do/apf/dataList/getCalendarCodes',
				method : 'post'					
			}
		});
		
		function getMaturitydate(pi) {
			var defer = $q.defer();
			ajaxService.getMaturitydate(pi).then(function(response) {
				defer.resolve(response);
			});
			return defer.promise;
		}
		function getCurrencyOptions() {
			var defer = $q.defer();
			ajaxService.getCurrencyOptions().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		function getCommunityCodeQOptions() {
			var defer = $q.defer();
			ajaxService.getCommunityCodeQOptions().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		function invoiceTypeOptions(piLoad) {
			var defer = $q.defer();
			ajaxService.getInvoiceTypeOptions(piLoad).then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		function getCalendarCodes() {
			var defer = $q.defer();
			ajaxService.getCalendarCodes().then(function(response) {
				defer.resolve(response ? response : {});
			});
			return defer.promise;
		};
		return {
			invoiceTypeOptions : invoiceTypeOptions,
			getCurrencyOptions : getCurrencyOptions,
			getCommunityCodeQOptions : getCommunityCodeQOptions,
			getMaturitydate : getMaturitydate,
			getCalendarCodes : getCalendarCodes
		};
	}
})(angular);